package com.hang.gymmanager.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hang.gymmanager.common.Response;
import com.hang.gymmanager.req.PageOrderReq;
import com.hang.gymmanager.res.OrderDetailRes;
import com.hang.gymmanager.res.PageOrderRes;
import com.hang.gymmanager.service.OrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 订单控制器
 * @author wyq
 * @version v1.0.0
 * @explain
 * @date 2024/3/22 15:10
 */
@RestController
@Slf4j
@RequestMapping("/order")
@RequiredArgsConstructor
@CrossOrigin
public class OrderController {

    private final OrderService orderService;

    /**
     * 订单列表查询
     * @param req
     * @return
     */
    @PostMapping("/all")
    public Response<Page<PageOrderRes>> pageAllOrder(@RequestBody PageOrderReq req){
        Page<PageOrderRes> res = orderService.pageAllOrder(req);
        return Response.success(res);

    }

    /**
     * 订单详情查询
     * @param orderId
     * @return
     */
    @GetMapping("/detail/{orderId}")
    public Response<OrderDetailRes> detail(@PathVariable Long orderId){
        OrderDetailRes res = orderService.detail(orderId);
        return Response.success(res);
    }


}
